$(function () {
    let username = sessionStorage.getItem("loginName");
    console.log(username, "username")
    if (username == null) {
        // location.href = "/login.html";
        window.open("/html/login.html", "_top");
    }
});


function myAjax(url, data, type) {
    let result = [];
    // data.loginName = sessionStorage.getItem("loginName");
    let login = {loginName: sessionStorage.getItem("loginName")};
    $.ajax({
        url: url,//地址：访问后台的地址
        data: Object.assign(data, login),//前端传递给后台的数据
        type: type,
        async: false,
        xhrFields: {
            withCredentials: true
        },
        crossDomain: true,
        dataType: 'json',//是后端传递到前端的数据格式
        success: function (getData) {//后端给前端的一个反馈
            console.log(getData);
            if (getData.data == "notLogin") {
                window.open("/login.html", "_top");
            } else {
                result = getData;
            }

        }
    });
    return result;
}